/**
 * Assignment 5               P5Circle.java                  Due July 20, 2011
 *
 * login: cs11ubn
 */

/**
 * A circle class that inherits P5Shape. Defines the area and volume functions
 * from Shape as well as overrides the toString method.
 */
public class P5Circle extends P5Shape
{
  // Declare our constants
  final double PI = Math.PI; // Get the value of pi
  protected double rad; // Holds the radius

  /**
   * No-arg ctor. Initializes radius to 1
   */
  public P5Circle()
  {
    // Initialize to one
    rad = 1;
  }

  /**
   * 1-arg ctor. Initialize to the given radius
   */
  public P5Circle(double radius)
  {
    rad = radius; // Set the radius to the given value
  }

  /**
   * Define the area method from the abstract super class
   */
  public double area()
  {
    return (PI * rad * rad); // Area is pi * r^2
  }

  /**
   * Overrides the toString method in P5Shape.
   */
  public String toString()
  {
    return ("Circle:\t\t" + rad + " radius"); // Output the toString
  }

  /**
   * Define the volume method from the abstract super class
   */
  public double volume()
  {
    return area(); // Volume is the area
  }
}
